<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<meta name="format-detection" content="telephone=no">
		<meta name="format-detection" content="email=no">
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<title>邀您加入启程考驾照</title>
		<link rel="stylesheet" href="../css/reset.css" />
		<style>
			.code{
				text-align: center;
				margin-top: 20%;
			}
			.text{
				padding: 20px;
				text-align: center;
				font-size: 1.6rem;
			}
			.ts{
				position: fixed;
				width: 100%;
				height: 30px;
				line-height: 30px;
				text-align: center;
				font-size: 1.5rem;
				background: #ffe7c9;
				color: #d78419;
				top: 0;
				left: 0;
			}
		</style>
	</head>
	<body>
		<img src="../images/logo.png" style="display: none;"  />
		<p style="display: none;">点击右上角分享给好友吧</p>
		<div class="ts">点击右上角分享给好友吧</div>
		<div class="code">
			<img src="../images/loading.gif" />
		</div>
		<!--<p class="text">长按识别二维码</p>-->
		<script type="text/javascript" src="../js/jquery-1.10.1.min.js" ></script>
		<script type="text/javascript" src="../js/get_url_parameter.js" ></script>
		<script type="text/javascript" src="../js/config.js" ></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script>
			var phone=""
			if(sessionStorage.getItem("phone")!=""&&sessionStorage.getItem("phone")!=undefined&&sessionStorage.getItem("phone")!=null){
				phone=sessionStorage.getItem("phone");
				var share_url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxce3ced320373d100&redirect_uri=http%3a%2f%2fapp.qcjkjg.com%2fstatic%2fhtml%2finstructor%2fwechat_invitation.html%3fshare_phone%3d"+phone+"%26share_from%3dwechat&response_type=code&scope=snsapi_base&state=123&connect_redirect=1#wechat_redirect"
				//$(".code img").attr("src","http://pan.baidu.com/share/qrcode?w=250&h=250&url="+encodeURIComponent(share_url))
				location.href=share_url;
			}
			else{
				var code=request("code");
				$.ajax({
				    url: DATA_URL+"checkwxbind",
				    data: "code="+code,
				    type: "post",
				    async: false,
				    dataType: 'json',
				    timeout: 5000,
				    success:function (data) {
				    	if(data.code=="0"){
				    		if(data.info.is_bind==1){
				    			phone=data.info.phone;
				    			sessionStorage.setItem("phone",data.info.phone);
				    			var share_url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxce3ced320373d100&redirect_uri=http%3a%2f%2fapp.qcjkjg.com%2fstatic%2fhtml%2finstructor%2fwechat_invitation.html%3fshare_phone%3d"+phone+"%26share_from%3dwechat&response_type=code&scope=snsapi_base&state=123&connect_redirect=1#wechat_redirect"
								//$(".code img").attr("src","http://pan.baidu.com/share/qrcode?w=250&h=250&url="+encodeURIComponent(share_url))
								location.href=share_url;
				    		}
				    		else{
				    			var open_id=data.info.open_id;
				    			location.href="binding_phone.html?open_id="+open_id
				    		}
				    	}
						else{
							$("#prompt").text(data.msg);
				            $(".prompt").fadeIn(300,function(){
				                setTimeout(function(){$(".prompt").fadeOut(300)},3000)
				            })
						}
				    },
				    error:function () {
				    	$("#prompt").text("您的网络不给力哦~");
				        $(".prompt").fadeIn(300,function(){
				            setTimeout(function(){$(".prompt").fadeOut(300)},3000)
				        })
				    }
				});
			}
		</script>
	</body>
</html>
